
//从下方翻上来
cc.Class({
    extends: cc.Component,

    properties: {
        ActionTime:1.2

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        if(this.node.getComponent(cc.Sprite)){     
            this.node.rotationX =-90        
        }
    },
    playAnime(CallBack,CallBack_Self,ActionTime,startTime){
        this.CallBack= CallBack
        this.CallBack_Self = CallBack_Self
        if(!ActionTime){
            this.ActionTime = 1.2
        }else{
            this.ActionTime = ActionTime
        }
        if(!startTime){
            this.startTime = 0
        }else{
            this.startTime =startTime
        }
    },

    update (dt) {
        if(this.startTime<this.ActionTime){
            this.startTime+=dt            
            this.node.rotationX = this.elasticOut(this.startTime,-90,90,this.ActionTime,1,0.8)
        }else if(this.startTime > this.ActionTime){
            this.node.rotationX = 0
            if(this.CallBack){
                this.CallBack(this.CallBack_Self?this.CallBack_Self:null)
                this.destroy()
            }

        }
     },
     elasticOut(t, b, c, d, a, p){    //正弦增强曲线（弹动渐出）
        if (t === 0) {
            return b;
        }
        if ( (t /= d) == 1 ) {
            return b+c;
        }
        if (!p) {
            p=d*0.3;
        }
        if (!a || a < Math.abs(c)) {
            a = c;
            var s = p / 4;
        } else {
            var s = p/(2*Math.PI) * Math.asin (c/a);
        }
        return a*Math.pow(2,-10*t) * Math.sin((t*d-s)*(2*Math.PI)/p) + c + b;
    },    
});
